PushRange Method (T[], Int32, Int32)

Task Parallel System.Threading

Inserts multiple objects at the top of the ConcurrentStack<(Of <(T>)>) atomically.

Namespace:  System.Collections.Concurrent
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Sub PushRange ( _
	items As T(), _
	startIndex As Integer, _
	count As Integer _
)
C#
public void PushRange(
	T[] items,
	int startIndex,
	int count
)

Parameters

items
Type: array< T >[]()[]
The objects to push onto the ConcurrentStack<(Of <(T>)>).
startIndex
Type: System..::.Int32
The zero-based offset in items at which to begin inserting elements onto the top of the ConcurrentStack<(Of <(T>)>).
count
Type: System..::.Int32
The number of elements to be inserted onto the top of the ConcurrentStack<(Of <(T>)>).

Remarks

When adding multiple items to the stack, using PushRange is a more efficient mechanism than using Push(T) one item at a time. Additionally, PushRange guarantees that all of the elements will be added atomically, meaning that no other threads will be able to inject elements between the elements being pushed. Items at lower indices in the items array will be pushed before items at higher indices.

Exceptions

ExceptionCondition
System..::.ArgumentNullExceptionitems is a null reference (Nothing in Visual Basic).
System..::.ArgumentOutOfRangeExceptionstartIndex or count is negative. Or startIndex is greater than or equal to the length of items.
System..::.ArgumentExceptionstartIndex + count is greater than the length of items.

See Also